﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using GUILayerWPF.FlightRoutingService;

namespace GUILayerWPF
{
    /// <summary>
    /// Interaction logic for PaymentSite.xaml
    /// </summary>

    public partial class PaymentSite : Window
    {
        //Variabler initialization
        private static FlightRouteServiceClient flightclient;
        private Customer mainCustomer;
        private Travel mainTravel;
        private string AccountNo;
        private string RegNummer;
        

        public PaymentSite(Travel _travel, Customer _customer)
        {
            InitializeComponent();
            flightclient = new FlightRouteServiceClient();
            mainCustomer = new Customer();
            mainTravel = new Travel();
            mainCustomer = _customer;
            mainTravel = _travel;
           
            CustomerInfoPrint();
            AddFlightToListBox();
            AccountNo = "9000294254";
            RegNummer = "0102";
        }
        //print out customer info
        private void CustomerInfoPrint()
        {
            PayerNameBox.Text = mainCustomer.FName + " " + mainCustomer.LName;
            PayerAdressBox.Text = mainCustomer.Address;
            PayerPhoneBox.Text = System.Convert.ToString(mainCustomer.PhoneNo);
        }
        //add flight to list box
        private void AddFlightToListBox()
        {
            double price;
            price = new double();
            
            foreach(SeatBooking sb in mainTravel.SeatBooks)
            {
                string retstring;
                retstring = "Fra: " + sb.FlightInstance.Flight.Departure.AirportName + ", Til: " + sb.FlightInstance.Flight.Arrival.AirportName + ", Pris: " + sb.FlightInstance.Flight.Price;
                ListBoxFLights.Items.Add(retstring);
                price += sb.FlightInstance.Flight.Price;
            }
            BoxPriceAll.Text = System.Convert.ToString(price);
        } 
        //no button
        private void PayerNo_Click(object sender, RoutedEventArgs e)
        {
            List<FlightInstance> fList = new List<FlightInstance>();
            foreach(SeatBooking sb in mainTravel.SeatBooks)
            {
                fList.Add(sb.FlightInstance);
                
            }
            List<Customer>mypersons = new List<Customer>();
            mypersons = mainTravel.Persons.ToList();
            SeatBookingGUI popupSeatBooking = new SeatBookingGUI(mainTravel, mainCustomer);
            popupSeatBooking.Show();
            this.Close();
        }
        //if check radiobuttom dankort
        private void RadioButtom_Dankort_Checked(object sender, RoutedEventArgs e)
        {
            collapsMastercard();
            collapsElectron();
            collapsBank();
            Payment1box.Visibility = System.Windows.Visibility.Visible;
            monthBox.Visibility = System.Windows.Visibility.Visible;
            yearBox.Visibility = System.Windows.Visibility.Visible;
            safetyNoBOx.Visibility = System.Windows.Visibility.Visible;
            CVChelpPic.Visibility = System.Windows.Visibility.Visible;
            CVChelp.Visibility = System.Windows.Visibility.Visible;
            PayermentinfoBox.Visibility = System.Windows.Visibility.Visible;
        }
        //if check radiobuttom masterCard
        private void RadioButtom_MasterCard_Checked(object sender, RoutedEventArgs e)
        {
            collapsDankort();
            collapsElectron();
            collapsBank();

            Masterinfo1.Visibility = System.Windows.Visibility.Visible;
            Payment1box.Visibility = System.Windows.Visibility.Visible;
            monthBox.Visibility = System.Windows.Visibility.Visible;
            yearBox.Visibility = System.Windows.Visibility.Visible;
            safetyNoBOx.Visibility = System.Windows.Visibility.Visible;
            CVCMasterhelpPic.Visibility = System.Windows.Visibility.Visible;
            PayermentinfoBox.Visibility = System.Windows.Visibility.Collapsed;

        }
        //if check radiobuttom Visa electron
        private void RadioButtom_VisaElectron_Checked(object sender, RoutedEventArgs e)
        {
            collapsDankort();
            collapsMastercard();
            collapsBank();

            CVCelectronhelpPic.Visibility = System.Windows.Visibility.Visible;
            electroninfo1.Visibility = System.Windows.Visibility.Visible;
            Payment1box.Visibility = System.Windows.Visibility.Visible;
            monthBox.Visibility = System.Windows.Visibility.Visible;
            yearBox.Visibility = System.Windows.Visibility.Visible;
            safetyNoBOx.Visibility = System.Windows.Visibility.Visible;
        }
        //if check radiobuttom bank 
        private void RadioButtom_Bank_Checked(object sender, RoutedEventArgs e)
        {
            collapsElectron();
            collapsDankort();
            collapsMastercard();

            regNummerLabel.Visibility = System.Windows.Visibility.Visible;
            accountNoLabel.Visibility = System.Windows.Visibility.Visible;
            infoLabel2.Visibility = System.Windows.Visibility.Visible;
            infoLabel1.Visibility = System.Windows.Visibility.Visible;
            BankInfo.Visibility = System.Windows.Visibility.Visible;

            regNummerLabel.Text = RegNummer;
            accountNoLabel.Text = AccountNo;


        }
        //Collaps bank 
        private void collapsBank()
        {
            regNummerLabel.Visibility = System.Windows.Visibility.Collapsed;
            accountNoLabel.Visibility = System.Windows.Visibility.Collapsed;
            infoLabel2.Visibility = System.Windows.Visibility.Collapsed;
            infoLabel1.Visibility = System.Windows.Visibility.Collapsed;
            BankInfo.Visibility = System.Windows.Visibility.Collapsed;
        }
        //Collaps Electron
        private void collapsElectron()
        {
            CVCelectronhelpPic.Visibility = System.Windows.Visibility.Collapsed;
            electroninfo1.Visibility = System.Windows.Visibility.Collapsed;
            Payment1box.Visibility = System.Windows.Visibility.Collapsed;
            monthBox.Visibility = System.Windows.Visibility.Collapsed;
            yearBox.Visibility = System.Windows.Visibility.Collapsed;
            safetyNoBOx.Visibility = System.Windows.Visibility.Collapsed;
        }
        //Collaps dankort
        private void collapsDankort()
        {
            Payment1box.Visibility = System.Windows.Visibility.Collapsed;
            monthBox.Visibility = System.Windows.Visibility.Collapsed;
            yearBox.Visibility = System.Windows.Visibility.Collapsed;
            safetyNoBOx.Visibility = System.Windows.Visibility.Collapsed;
            CVChelpPic.Visibility = System.Windows.Visibility.Collapsed;
            CVChelp.Visibility = System.Windows.Visibility.Collapsed;
            PayermentinfoBox.Visibility = System.Windows.Visibility.Collapsed;
        }
        //Collaps MasterCard
        private void collapsMastercard()
        {
            Payment1box.Visibility = System.Windows.Visibility.Collapsed;
            monthBox.Visibility = System.Windows.Visibility.Collapsed;
            yearBox.Visibility = System.Windows.Visibility.Collapsed;
            safetyNoBOx.Visibility = System.Windows.Visibility.Collapsed;
            Masterinfo1.Visibility = System.Windows.Visibility.Collapsed;
            CVCMasterhelpPic.Visibility = System.Windows.Visibility.Collapsed;
        }
    }
}
                    